package com.junzhiit.nengji.api.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import com.junzhiit.nengji.api.service.GoodsHistoryService;

@Configuration
@EnableScheduling
public class SchedulingConfig {

	private final Logger logger = LoggerFactory.getLogger(getClass());
	
	@Autowired
	private GoodsHistoryService goodsHistoryService;
	
/*	@Scheduled(cron = "0 0 1 * * ?")
	public void execute(){

		for(int i = 0;i<1000;i++){
			System.out.println("*");
		}
		//超过24小时的订单更新为无效
		logger.info("update orders status run...");
		
		logger.info("end...");
	}*/
	
	@Scheduled(cron = "0 0 1 * * ?")
	public void addGoodsHistory(){
		
		//把redis前一天的goodsHistory数据插入数据库
		logger.info("run...");
		goodsHistoryService.add();
		logger.info("end...");
		
	}
}
